package com.dycong.common.leetcode.yi;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yilin
 * Date: 2019-08-19
 * Time: 14:58
 */
public class RemoveDulcData {

    public int removeDuplicates(int[] nums) {
        if (nums == null || nums.length <= 0) return 0;

        int k = 1;
        int length = nums.length;
        int p = nums[0];
        for (int i = 1; i < length; i++) {
            if (p != nums[i]) {
                //重新设置新数组的值
                nums[k++] = nums[i];
                p = nums[i];
            }
        }
        return k;
    }
}
